﻿<!DOCTYPE html>
<!--Authors: Milan Švancara & Ondřej Wojewoda & Michal Huťka & Daniel Meisner-->
<html>
<head>
<?php include "base-files/head.php" //Vkládá připravenou hlavičku - atributy dopisovat do souboru head.php!!!! ?> 
</head>
<body>
<?php setcookie("nav","admin");
$temp_nav = "admin"; ?>
<?php include "login.php" ?> 
<?php include "funkce_admin.php"; ?>
<?php include "../php-library/pripojeni_na_mysqli.php"; ?>
<div class="ejkej">  
<?php include "base-files/menu.php"; ?>

<h3>Změna hesla</h3>

<div class ="formularAdmin">
<FORM method = "post" action="<?php echo $_SERVER["PHP_SELF"]?>"> 
<div class ="kolonkaAdmin"> Nové: <input name = "zadaneNoveHeslo1" type="password" id="nazev_predmetu" value="<?php echo $_POST['nazev_predmetu']; ?>" /> <br /></div>
<div class ="kolonkaAdmin"> Znovu zadejte nové: <input name = "zadaneNoveHeslo2" type="password" id="nazev_predmetu" value="<?php echo $_POST['nazev_predmetu']; ?>" /> <br /></div>
</div>
<div class ="kolonka2"><input name = "zmenHeslo" type = "submit" value = "Uložit změny" /><br /></div>
</FORM>
<?php 
if(isset($_POST["zadaneNoveHeslo1"])){
	if($_POST["zadaneNoveHeslo1"] == $_POST["zadaneNoveHeslo2"]){
			$noveHeslo = md5($_POST["zadaneNoveHeslo1"]);	
			mysqli_query($GLOBALS["pripojeni"], "UPDATE `uzivatele` SET `heslo` = '$noveHeslo'");
		}
	else{
			echo "Zadané hesla se neschodojí.";
		}	
}
?>
<h3>Změna loginu</h3>

<div class ="formularAdmin">
<FORM method = "post" action="<?php echo $_SERVER["PHP_SELF"]?>"> 
<div class ="kolonkaAdmin"> Nové: <input name = "zadanyNovyLogin" value="<?php echo $_POST['nazev_predmetu']; ?>" /> <br /></div>
</div>
<div class ="kolonka2"><input name = "zmenLogin" type = "submit" value = "Uložit změny" /><br /></div>
</FORM>


<?php 
if(isset($_POST["zadanyNovyLogin"])){
$novyLogin = $_POST["zadanyNovyLogin"];	
mysqli_query($GLOBALS["pripojeni"], "UPDATE `uzivatele` SET `login` = '$novyLogin'");
echo $novyLogin;

}
?>
</body>
</html>